package com.hadoop.project.mvc.controller;

import com.hadoop.project.entity.po.UserFlavor;
import com.hadoop.project.entity.query.UserFlavorQuery;
import com.hadoop.project.entity.vo.ResponseVO;
import com.hadoop.project.mvc.service.UserFlavorService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: Controller
 * @author:alexmaodali
 * @date:2025/4/13
 */
@RestController
@ApiOperation(value = "标签排名接口")
@RequestMapping("/userFlavor")
public class UserFlavorController extends ABaseController {

	private static final Logger log = LoggerFactory.getLogger(UserFlavorController.class);
	@Resource
	private UserFlavorService userFlavorService;

	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("loadDataList")
	public ResponseVO loadDataList(UserFlavorQuery query) {
		return getSuccessResponseVO(userFlavorService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("add")
	public ResponseVO add(UserFlavor bean) {
		log.info("新增数据{}", bean);
		this.userFlavorService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<UserFlavor> listBean) {
		System.out.println("listBean = " + listBean);
		this.userFlavorService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增或修改
	 */
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<UserFlavor> listBean) {
		this.userFlavorService.addOrUpdateBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询
	 */
	@RequestMapping("getUserFlavorById")
	public ResponseVO  getUserFlavorById( Long id) {
		return getSuccessResponseVO(this.userFlavorService.getUserFlavorById(id));
	}

	/**
	 * 根据Id更新
	 */
	@RequestMapping("updateUserFlavorById")
	public ResponseVO updateUserFlavorById(UserFlavor bean,Long id) {
		this.userFlavorService.updateUserFlavorById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("deleteUserFlavorById")
	public ResponseVO deleteUserFlavorById(Long id) {
		this.userFlavorService.deleteUserFlavorById(id);
		return getSuccessResponseVO(null);
	}


}
